﻿using Colorful.Control.Services;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Colorful.Control;
using System.Collections.Generic;

namespace Colorful.Test.Integration
{       
    /// <summary>
    ///This is a test class for AdobeKulerTest and is intended
    ///to contain all AdobeKulerTest Unit Tests
    ///</summary>
    [TestClass]
    public class AdobeKulerTest
    {       
        /// <summary>
        ///A test to check which color lists are supported by the service.
        ///</summary>
        [TestMethod]
        public void SupportedListsTest()
        {
            AdobeKuler target = new AdobeKuler();
            List<ColorList> expected = new List<ColorList>() 
                                {
                                    ColorList.Popular,
                                    ColorList.Random,                                   
                                    ColorList.Rating,
                                    ColorList.Recent,
                                    ColorList.Search
                                };

            IEnumerable<ColorList> actual = target.SupportedLists;

            foreach (ColorList list in actual)
                Assert.IsTrue(expected.Contains(list));
        }
        
        /// <summary>
        /// A test to check that we can search for colors from the service.
        /// </summary>
        [TestMethod]
        public void SearchForColorsTest()
        {
            int totalItems = 0;
            AdobeKuler target = new AdobeKuler();
            IEnumerable<Palette> actual = target.Search("snow", 0, 10, out totalItems);
            List<Palette> actualList = new List<Palette>(actual);
            Assert.AreEqual<int>(10, actualList.Count);    
        }

        /// <summary>
        /// A test to check that we can get recent colors from the service.
        /// </summary>
        [TestMethod]
        public void GetRecentColorsTest()
        {
            int totalItems = 0;
            AdobeKuler target = new AdobeKuler();
            IEnumerable<Palette> actual = target.GetColors(ColorList.Recent, 0, 10, out totalItems);
            List<Palette> actualList = new List<Palette>(actual);
            Assert.AreEqual<int>(10, actualList.Count);            
        }

        /// <summary>
        /// A test to check that we can get popular colors from the service.
        /// </summary>
        [TestMethod]
        public void GetPopularColorsTest()
        {
            int totalItems = 0;
            AdobeKuler target = new AdobeKuler();
            IEnumerable<Palette> actual = target.GetColors(ColorList.Popular, 0, 10, out totalItems);
            List<Palette> actualList = new List<Palette>(actual);
            Assert.AreEqual<int>(10, actualList.Count);
        }

        /// <summary>
        /// A test to check that we can get rated colors from the service.
        /// </summary>
        [TestMethod]
        public void GetRatedColorsTest()
        {
            int totalItems = 0;
            AdobeKuler target = new AdobeKuler();
            IEnumerable<Palette> actual = target.GetColors(ColorList.Rating, 0, 10, out totalItems);
            List<Palette> actualList = new List<Palette>(actual);
            Assert.AreEqual<int>(10, actualList.Count);
        }

        /// <summary>
        /// A test to check that we can get random colors from the service.
        /// </summary>
        [TestMethod]
        public void GetRandomColorsTest()
        {
            int totalItems = 0;
            AdobeKuler target = new AdobeKuler();
            IEnumerable<Palette> actual = target.GetColors(ColorList.Random, 0, 10, out totalItems);
            List<Palette> actualList = new List<Palette>(actual);
            Assert.AreEqual<int>(10, actualList.Count);
        }

        /// <summary>
        ///A test for AdobeKuler Constructor
        ///</summary>
        [TestMethod]
        public void AdobeKulerConstructorTest()
        {
            AdobeKuler target = new AdobeKuler();
            Assert.IsNotNull(target);
        }
    }
}
